/*
 * JPatient.java
 *
 * Created on 18. Mai 2008, 10:34
 */

package ocumed.presentation.patient;

import java.awt.Frame;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JDialog;
import javax.swing.JPanel;
import ocumed.teams.teamb.gui.PRezeptErstellen;

/**
 *
 * @author  apr3455
 */
public class JPatientBearbeiten extends javax.swing.JDialog {
    
    Integer m_patientId = null;
    String m_frameTitle;
    
    /** Creates new form JPatient */
    public JPatientBearbeiten(Frame frame, boolean modal, int patientId, String patientName) {
        super(frame, modal);
        m_frameTitle = patientName;
        if(m_frameTitle == null){
            m_frameTitle = "Neuer Patient";
        } else {
            m_frameTitle += " - Bearbeitung";
        }
        m_patientId = patientId;
        initComponents();
        initControls();
    }

    public void setVisibleTab(int index){
        jTabbedPane1.setSelectedIndex(index);
    }
    
    private void initControls() {
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        addWindowListener(new WindowListener() {

            public void windowOpened(WindowEvent arg0) {

            }

            public void windowClosing(WindowEvent arg0) {
                dispose();
            }

            public void windowClosed(WindowEvent arg0) {

            }

            public void windowIconified(WindowEvent arg0) {

            }

            public void windowDeiconified(WindowEvent arg0) {

            }

            public void windowActivated(WindowEvent arg0) {

            }

            public void windowDeactivated(WindowEvent arg0) {

            }
        });
        
        if(m_patientId != -1){
            jTabbedPane1.addTab("Patient Bearbeiten", new JPanel());
            jTabbedPane1.addTab("Rezept Erstellen", new PRezeptErstellen(m_patientId));
            jTabbedPane1.addTab("Anamnese Daten", new JPanel());
            jTabbedPane1.addTab("Termine", new JPanel());
        } else {
            jTabbedPane1.addTab("Patient anlegen", new PPatientAnlegen(this));
        }
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        besitztEcardGroup = new javax.swing.ButtonGroup();
        geschlechtGroup = new javax.swing.ButtonGroup();
        jLabel11 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();

        org.jdesktop.layout.GroupLayout jFrame1Layout = new org.jdesktop.layout.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        setTitle(m_frameTitle);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(186, 186, 186)
                        .add(jLabel11))
                    .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 878, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel11)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    /**
     * @param args the command line arguments
     */

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup besitztEcardGroup;
    private javax.swing.ButtonGroup geschlechtGroup;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables


}
